var longestPalindrome = function (s) {
    if (s.length === 1) return 1;
    let obj = {};
    let len = s.length
    for (let i = 0; i < len; i++) {
        if (obj[s[i]] == undefined) {
            obj[s[i]] = 1;
        } else {
            obj[s[i]] += 1;
        }
    }
    let arr = Object.values(obj);
    console.log(arr);

    let max = 0;
    let sum = 0;
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] % 2 === 0) {
            continue;
        } else {
            sum += arr[i];
            if (arr[i] > max) max = arr[i];
        }
    }
    console.log(len, sum, max);

    return (len - sum + max)
};
s = "adam";
console.log(longestPalindrome(s));


